AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )

function ENT:Initialize()
self:SetModel( "models/props/cs_assault/TicketMachine.mdl" )
self:SetSolid(  SOLID_BBOX ) 
self:SetUseType( SIMPLE_USE )
self:DropToFloor()
end

function ENT:OnTakeDamage( dmg ) 
 return false
end

function ENT:AcceptInput( Name, Activator, Caller )	
	if Name == "Use" and Caller:IsPlayer() then
		umsg.Start("ShowBank", Caller)
		umsg.End()	
	end
end

concommand.Add( "bank_deposit", function( ply, cmd, args )
local amount = tonumber(args[1])
	if (not amount) or (amount < 1) then return end
		if not tonumber(args[1]) then return end 
				if tonumber(ply:GetPData("cash")) >= amount then
					ply:AddCash(-args[1])
					ply:SetPData("bank", ply:GetPData( "bank" ) + args[1]);
					ply:ChatPrint("You deposited $"..args[1].." to your bank account.")
		end
end )

concommand.Add( "bank_withdraw", function( ply, cmd, args )
local amount = tonumber(args[1])
	if (not amount) or (amount < 1) then return end
		if not tonumber(args[1]) then return end 
				if tonumber(ply:GetPData("bank")) >= amount then
					ply:AddCash(args[1])
					ply:SetPData("bank", ply:GetPData( "bank" ) - args[1]);
					ply:ChatPrint("You withdrew $"..args[1].." from your bank account.")
		end
end )